#ifndef MEMBERSHIPHISTORYMANAGER_H
#define MEMBERSHIPHISTORYMANAGER_H

#include <map>

#include "ISerializable.h"
#include "MembershipHistory.h"

class MembershipHistoryManager : public ISerializable
{
public:
  typedef std::map<std::string, MembershipHistory> MembershipHistoryMap;
  typedef std::pair<std::string, MembershipHistory> MembershipHistoryPair;

  MembershipHistoryManager()
  {    
  }

  virtual ~MembershipHistoryManager()
  {
  }

  const MembershipHistoryMap& histories() const { return m_histories; }
  const MembershipHistory *historyById(const std::string &id) const;
  virtual bool serialize(const std::string& fileName) const;
  virtual bool deserialize(const std::string& fileName);
  void clear() { m_histories.clear(); }
  std::string newHistoryId() const;

  void insert(const MembershipHistory& history)
  {
    m_histories[history.id()] = history;
  }

  int size() const { return static_cast<int>(m_histories.size()); }

private:
  MembershipHistoryMap m_histories;
};

#endif // MEMBERSHIPHISTORYMANAGER_H